
DELETE FROM XJEquipmentStockInDetail WHERE EquipmentId NOT IN
(
SELECT Id FROM XJEquipment
WHERE IsConsumables = 1
)
GO
DELETE FROM XJEquipmentStockOutDetail WHERE EquipmentId NOT IN
(
SELECT Id FROM XJEquipment
WHERE IsConsumables = 1
)
GO
DELETE FROM XJEquipmentStockLog WHERE EquipmentId NOT IN
(
SELECT Id FROM XJEquipment
WHERE IsConsumables = 1
)
GO
DELETE FROM XJEquipmentStockIn
WHERE Id NOT IN
(
SELECT EquipmentStockInId FROM XJEquipmentStockInDetail
)
GO
DELETE FROM XJEquipmentStockOut
WHERE Id NOT IN
(
SELECT EquipmentStockOutId FROM XJEquipmentStockOutDetail
)
GO
UPDATE XJEquipment
SET Stock = 0,StockMin = 0,Freeze = 0
WHERE IsConsumables = 0